/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.caresms.model.impl;

import com.caresms.model.Keyword_Master;
import com.caresms.model.Keyword_MasterModel;
import com.caresms.model.Keyword_MasterSoap;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The base model implementation for the Keyword_Master service. Represents a row in the &quot;sms_Keyword_Master&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.caresms.model.Keyword_MasterModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link Keyword_MasterImpl}.
 * </p>
 *
 * @author cc
 * @see Keyword_MasterImpl
 * @see com.caresms.model.Keyword_Master
 * @see com.caresms.model.Keyword_MasterModel
 * @generated
 */
@JSON(strict = true)
public class Keyword_MasterModelImpl extends BaseModelImpl<Keyword_Master>
	implements Keyword_MasterModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a keyword_ master model instance should use the {@link com.caresms.model.Keyword_Master} interface instead.
	 */
	public static final String TABLE_NAME = "sms_Keyword_Master";
	public static final Object[][] TABLE_COLUMNS = {
			{ "KeyId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "userId", Types.BIGINT },
			{ "KeywordName", Types.VARCHAR },
			{ "createDate", Types.TIMESTAMP },
			{ "Created_By", Types.BIGINT },
			{ "isActive", Types.BOOLEAN },
			{ "Cat_Id", Types.BIGINT },
			{ "field1", Types.VARCHAR },
			{ "field2", Types.BOOLEAN },
			{ "field3", Types.INTEGER },
			{ "field4", Types.TIMESTAMP },
			{ "field5", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table sms_Keyword_Master (KeyId LONG not null primary key,companyId LONG,userId LONG,KeywordName VARCHAR(75) null,createDate DATE null,Created_By LONG,isActive BOOLEAN,Cat_Id LONG,field1 VARCHAR(75) null,field2 BOOLEAN,field3 INTEGER,field4 DATE null,field5 VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table sms_Keyword_Master";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.caresms.model.Keyword_Master"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.caresms.model.Keyword_Master"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.caresms.model.Keyword_Master"),
			true);
	public static long CREATED_BY_COLUMN_BITMASK = 1L;
	public static long KEYID_COLUMN_BITMASK = 2L;
	public static long KEYWORDNAME_COLUMN_BITMASK = 4L;
	public static long ISACTIVE_COLUMN_BITMASK = 8L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static Keyword_Master toModel(Keyword_MasterSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		Keyword_Master model = new Keyword_MasterImpl();

		model.setKeyId(soapModel.getKeyId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setUserId(soapModel.getUserId());
		model.setKeywordName(soapModel.getKeywordName());
		model.setCreateDate(soapModel.getCreateDate());
		model.setCreated_By(soapModel.getCreated_By());
		model.setIsActive(soapModel.getIsActive());
		model.setCat_Id(soapModel.getCat_Id());
		model.setField1(soapModel.getField1());
		model.setField2(soapModel.getField2());
		model.setField3(soapModel.getField3());
		model.setField4(soapModel.getField4());
		model.setField5(soapModel.getField5());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<Keyword_Master> toModels(Keyword_MasterSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<Keyword_Master> models = new ArrayList<Keyword_Master>(soapModels.length);

		for (Keyword_MasterSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.caresms.model.Keyword_Master"));

	public Keyword_MasterModelImpl() {
	}

	public long getPrimaryKey() {
		return _KeyId;
	}

	public void setPrimaryKey(long primaryKey) {
		setKeyId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_KeyId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return Keyword_Master.class;
	}

	public String getModelClassName() {
		return Keyword_Master.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("KeyId", getKeyId());
		attributes.put("companyId", getCompanyId());
		attributes.put("userId", getUserId());
		attributes.put("KeywordName", getKeywordName());
		attributes.put("createDate", getCreateDate());
		attributes.put("Created_By", getCreated_By());
		attributes.put("isActive", getIsActive());
		attributes.put("Cat_Id", getCat_Id());
		attributes.put("field1", getField1());
		attributes.put("field2", getField2());
		attributes.put("field3", getField3());
		attributes.put("field4", getField4());
		attributes.put("field5", getField5());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long KeyId = (Long)attributes.get("KeyId");

		if (KeyId != null) {
			setKeyId(KeyId);
		}

		Long companyId = (Long)attributes.get("companyId");

		if (companyId != null) {
			setCompanyId(companyId);
		}

		Long userId = (Long)attributes.get("userId");

		if (userId != null) {
			setUserId(userId);
		}

		String KeywordName = (String)attributes.get("KeywordName");

		if (KeywordName != null) {
			setKeywordName(KeywordName);
		}

		Date createDate = (Date)attributes.get("createDate");

		if (createDate != null) {
			setCreateDate(createDate);
		}

		Long Created_By = (Long)attributes.get("Created_By");

		if (Created_By != null) {
			setCreated_By(Created_By);
		}

		Boolean isActive = (Boolean)attributes.get("isActive");

		if (isActive != null) {
			setIsActive(isActive);
		}

		Long Cat_Id = (Long)attributes.get("Cat_Id");

		if (Cat_Id != null) {
			setCat_Id(Cat_Id);
		}

		String field1 = (String)attributes.get("field1");

		if (field1 != null) {
			setField1(field1);
		}

		Boolean field2 = (Boolean)attributes.get("field2");

		if (field2 != null) {
			setField2(field2);
		}

		Integer field3 = (Integer)attributes.get("field3");

		if (field3 != null) {
			setField3(field3);
		}

		Date field4 = (Date)attributes.get("field4");

		if (field4 != null) {
			setField4(field4);
		}

		String field5 = (String)attributes.get("field5");

		if (field5 != null) {
			setField5(field5);
		}
	}

	@JSON
	public long getKeyId() {
		return _KeyId;
	}

	public void setKeyId(long KeyId) {
		_columnBitmask |= KEYID_COLUMN_BITMASK;

		if (!_setOriginalKeyId) {
			_setOriginalKeyId = true;

			_originalKeyId = _KeyId;
		}

		_KeyId = KeyId;
	}

	public long getOriginalKeyId() {
		return _originalKeyId;
	}

	@JSON
	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	@JSON
	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	@JSON
	public String getKeywordName() {
		if (_KeywordName == null) {
			return StringPool.BLANK;
		}
		else {
			return _KeywordName;
		}
	}

	public void setKeywordName(String KeywordName) {
		_columnBitmask |= KEYWORDNAME_COLUMN_BITMASK;

		if (_originalKeywordName == null) {
			_originalKeywordName = _KeywordName;
		}

		_KeywordName = KeywordName;
	}

	public String getOriginalKeywordName() {
		return GetterUtil.getString(_originalKeywordName);
	}

	@JSON
	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	@JSON
	public long getCreated_By() {
		return _Created_By;
	}

	public void setCreated_By(long Created_By) {
		_columnBitmask |= CREATED_BY_COLUMN_BITMASK;

		if (!_setOriginalCreated_By) {
			_setOriginalCreated_By = true;

			_originalCreated_By = _Created_By;
		}

		_Created_By = Created_By;
	}

	public long getOriginalCreated_By() {
		return _originalCreated_By;
	}

	@JSON
	public boolean getIsActive() {
		return _isActive;
	}

	public boolean isIsActive() {
		return _isActive;
	}

	public void setIsActive(boolean isActive) {
		_columnBitmask |= ISACTIVE_COLUMN_BITMASK;

		if (!_setOriginalIsActive) {
			_setOriginalIsActive = true;

			_originalIsActive = _isActive;
		}

		_isActive = isActive;
	}

	public boolean getOriginalIsActive() {
		return _originalIsActive;
	}

	@JSON
	public long getCat_Id() {
		return _Cat_Id;
	}

	public void setCat_Id(long Cat_Id) {
		_Cat_Id = Cat_Id;
	}

	@JSON
	public String getField1() {
		if (_field1 == null) {
			return StringPool.BLANK;
		}
		else {
			return _field1;
		}
	}

	public void setField1(String field1) {
		_field1 = field1;
	}

	@JSON
	public boolean getField2() {
		return _field2;
	}

	public boolean isField2() {
		return _field2;
	}

	public void setField2(boolean field2) {
		_field2 = field2;
	}

	@JSON
	public int getField3() {
		return _field3;
	}

	public void setField3(int field3) {
		_field3 = field3;
	}

	@JSON
	public Date getField4() {
		return _field4;
	}

	public void setField4(Date field4) {
		_field4 = field4;
	}

	@JSON
	public String getField5() {
		if (_field5 == null) {
			return StringPool.BLANK;
		}
		else {
			return _field5;
		}
	}

	public void setField5(String field5) {
		_field5 = field5;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
			Keyword_Master.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public Keyword_Master toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (Keyword_Master)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		Keyword_MasterImpl keyword_MasterImpl = new Keyword_MasterImpl();

		keyword_MasterImpl.setKeyId(getKeyId());
		keyword_MasterImpl.setCompanyId(getCompanyId());
		keyword_MasterImpl.setUserId(getUserId());
		keyword_MasterImpl.setKeywordName(getKeywordName());
		keyword_MasterImpl.setCreateDate(getCreateDate());
		keyword_MasterImpl.setCreated_By(getCreated_By());
		keyword_MasterImpl.setIsActive(getIsActive());
		keyword_MasterImpl.setCat_Id(getCat_Id());
		keyword_MasterImpl.setField1(getField1());
		keyword_MasterImpl.setField2(getField2());
		keyword_MasterImpl.setField3(getField3());
		keyword_MasterImpl.setField4(getField4());
		keyword_MasterImpl.setField5(getField5());

		keyword_MasterImpl.resetOriginalValues();

		return keyword_MasterImpl;
	}

	public int compareTo(Keyword_Master keyword_Master) {
		long primaryKey = keyword_Master.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		Keyword_Master keyword_Master = null;

		try {
			keyword_Master = (Keyword_Master)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = keyword_Master.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		Keyword_MasterModelImpl keyword_MasterModelImpl = this;

		keyword_MasterModelImpl._originalKeyId = keyword_MasterModelImpl._KeyId;

		keyword_MasterModelImpl._setOriginalKeyId = false;

		keyword_MasterModelImpl._originalKeywordName = keyword_MasterModelImpl._KeywordName;

		keyword_MasterModelImpl._originalCreated_By = keyword_MasterModelImpl._Created_By;

		keyword_MasterModelImpl._setOriginalCreated_By = false;

		keyword_MasterModelImpl._originalIsActive = keyword_MasterModelImpl._isActive;

		keyword_MasterModelImpl._setOriginalIsActive = false;

		keyword_MasterModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<Keyword_Master> toCacheModel() {
		Keyword_MasterCacheModel keyword_MasterCacheModel = new Keyword_MasterCacheModel();

		keyword_MasterCacheModel.KeyId = getKeyId();

		keyword_MasterCacheModel.companyId = getCompanyId();

		keyword_MasterCacheModel.userId = getUserId();

		keyword_MasterCacheModel.KeywordName = getKeywordName();

		String KeywordName = keyword_MasterCacheModel.KeywordName;

		if ((KeywordName != null) && (KeywordName.length() == 0)) {
			keyword_MasterCacheModel.KeywordName = null;
		}

		Date createDate = getCreateDate();

		if (createDate != null) {
			keyword_MasterCacheModel.createDate = createDate.getTime();
		}
		else {
			keyword_MasterCacheModel.createDate = Long.MIN_VALUE;
		}

		keyword_MasterCacheModel.Created_By = getCreated_By();

		keyword_MasterCacheModel.isActive = getIsActive();

		keyword_MasterCacheModel.Cat_Id = getCat_Id();

		keyword_MasterCacheModel.field1 = getField1();

		String field1 = keyword_MasterCacheModel.field1;

		if ((field1 != null) && (field1.length() == 0)) {
			keyword_MasterCacheModel.field1 = null;
		}

		keyword_MasterCacheModel.field2 = getField2();

		keyword_MasterCacheModel.field3 = getField3();

		Date field4 = getField4();

		if (field4 != null) {
			keyword_MasterCacheModel.field4 = field4.getTime();
		}
		else {
			keyword_MasterCacheModel.field4 = Long.MIN_VALUE;
		}

		keyword_MasterCacheModel.field5 = getField5();

		String field5 = keyword_MasterCacheModel.field5;

		if ((field5 != null) && (field5.length() == 0)) {
			keyword_MasterCacheModel.field5 = null;
		}

		return keyword_MasterCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(27);

		sb.append("{KeyId=");
		sb.append(getKeyId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append(", KeywordName=");
		sb.append(getKeywordName());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", Created_By=");
		sb.append(getCreated_By());
		sb.append(", isActive=");
		sb.append(getIsActive());
		sb.append(", Cat_Id=");
		sb.append(getCat_Id());
		sb.append(", field1=");
		sb.append(getField1());
		sb.append(", field2=");
		sb.append(getField2());
		sb.append(", field3=");
		sb.append(getField3());
		sb.append(", field4=");
		sb.append(getField4());
		sb.append(", field5=");
		sb.append(getField5());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(43);

		sb.append("<model><model-name>");
		sb.append("com.caresms.model.Keyword_Master");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>KeyId</column-name><column-value><![CDATA[");
		sb.append(getKeyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>KeywordName</column-name><column-value><![CDATA[");
		sb.append(getKeywordName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>Created_By</column-name><column-value><![CDATA[");
		sb.append(getCreated_By());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>isActive</column-name><column-value><![CDATA[");
		sb.append(getIsActive());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>Cat_Id</column-name><column-value><![CDATA[");
		sb.append(getCat_Id());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>field1</column-name><column-value><![CDATA[");
		sb.append(getField1());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>field2</column-name><column-value><![CDATA[");
		sb.append(getField2());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>field3</column-name><column-value><![CDATA[");
		sb.append(getField3());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>field4</column-name><column-value><![CDATA[");
		sb.append(getField4());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>field5</column-name><column-value><![CDATA[");
		sb.append(getField5());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = Keyword_Master.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			Keyword_Master.class
		};
	private long _KeyId;
	private long _originalKeyId;
	private boolean _setOriginalKeyId;
	private long _companyId;
	private long _userId;
	private String _userUuid;
	private String _KeywordName;
	private String _originalKeywordName;
	private Date _createDate;
	private long _Created_By;
	private long _originalCreated_By;
	private boolean _setOriginalCreated_By;
	private boolean _isActive;
	private boolean _originalIsActive;
	private boolean _setOriginalIsActive;
	private long _Cat_Id;
	private String _field1;
	private boolean _field2;
	private int _field3;
	private Date _field4;
	private String _field5;
	private long _columnBitmask;
	private Keyword_Master _escapedModelProxy;
}